package cn.hesion.leetcode;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PrimitiveIterator;

public class MissingNumber {

    public int missingNumber(int[] nums) {
        int xor = 0;
        int n = nums.length;
        for (int i = 0; i <n; i++) {
            xor ^=nums[i];
        }
        for (int i = 0; i <= n; i++) {
            xor ^=i;
        }

        return xor;
    }

    public static void main(String[] args) {
        MissingNumber missingNumber = new MissingNumber();
        System.out.println(System.currentTimeMillis());
        System.out.println(missingNumber.missingNumber(new int[]{3, 0, 1}));
        System.out.println(System.currentTimeMillis());
    }
}
